import { createBrowserRouter } from 'react-router-dom'
import { lazy, Suspense } from 'react'
import GeekLayout from '@/pages/GeekLayout'
import Login from '@/pages/Login'
import AuthRoot from '@/components/AuthRoute'
// 路由懒加载
const Home = lazy(() => import('@/pages/Home'))
const Article = lazy(() => import('@/pages/Article'))
const Publish = lazy(() => import('@/pages/Publish'))
const router = createBrowserRouter([
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/',
    element: <AuthRoot><GeekLayout /></AuthRoot>,
    children: [
      {
        index: true,
        element: <Suspense><Home /></Suspense>  
      },
      {
        path: '/article',
        element: <Suspense><Article /></Suspense>  
      },
      {
        path: '/publish',
        element: <Suspense><Publish /></Suspense>  
      },
    ]
  },
])

export default router